package cn.yyx;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import java.text.SimpleDateFormat;
@SpringBootApplication
@MapperScan({"cn.yyx.aclservice.mapper",
        "cn.yyx.empservice.mapper",
        "cn.yyx.performancestepservice.mapper",
        "cn.yyx.aftersaleservice.mapper",
        "cn.yyx.orderservice.mapper",
        "cn.yyx.stockservice.mapper",
        "cn.yyx.staservice.mapper",

        "cn.yyx.customerservice.mapper",
        "cn.yyx.financeservice.mapper"
})
public class YyxApplication {
    public static void main(String[] args) {
        SpringApplication.run(YyxApplication.class);
    }
    @Bean
    MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return  interceptor;
    }
    @InitBinder
    public void initBinder(WebDataBinder binder) {
        //创建一个日期格式化的类对象
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        //追加一个自定义的转换器：如果遇到java.util.Date 则使用我们定义好的日期格式化对象
        //指定的格式来转换
        //其中false 表示属性可以为空
        binder.registerCustomEditor(java.util.Date.class,new CustomDateEditor(format,false));
    }
}